package com.wordsay.context;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.wordsay.entity.AnalystResult;
import com.wordsay.entity.Dialog;
import com.wordsay.entity.GroupDialog;
import com.wordsay.entity.OverallAnalystResult;
import com.wordsay.entity.PersonDialog;
import com.wordsay.entity.PersonSimilarResult;

public class Resource {

	private Map<String,PersonDialog> personDialogs = new HashMap<String,PersonDialog>();
	private Map<String,GroupDialog> groupDialogs = new HashMap<String,GroupDialog>();
	private Map<String,GroupDialog> discussionDialogs = new HashMap<String,GroupDialog>();
	private OverallAnalystResult overallAnalystResult = new OverallAnalystResult();
	private List<PersonSimilarResult> personSimilareResult = new ArrayList<PersonSimilarResult>();
	
	/**
	 * find the similar result by id 
	 * @param id
	 * @return
	 */
	public PersonSimilarResult findSimilarResultById(String id){
		
		 if(this.personSimilareResult == null || this.personSimilareResult.size() == 0){
			 
			 return null;
		 }
		 
		 for(int i = 0; i < this.personSimilareResult.size();i++){
			 
			 PersonSimilarResult result = this.personSimilareResult.get(i);
			 if(result.getPersonA().trim().equals(id) || result.getPersonB().trim().equals(id)){
				 
				 return result;
			 }
		 }
		 return null;
	}
	
	/**
	 * find the analyst result by person/group/discussion id
	 * @param id
	 * @param type
	 * @return
	 */
	public AnalystResult findResultById(String id, String type){
		
		
		if(type.equalsIgnoreCase("person")){
			
			return personDialogs.get(id).getAnalystResult();
			
		}else if(type.equalsIgnoreCase("group")){
			
			return groupDialogs.get(id).getAnalystResult();
			
		}else if(type.equalsIgnoreCase("discussion")){
			
			return discussionDialogs.get(id).getAnalystResult();
			
		}else{
			
			return null;
		}
		
	}
	
	
	public Map<String, PersonDialog> getPersonDialogs() {
		return personDialogs;
	}
	public void setPersonDialogs(Map<String, PersonDialog> personDialogs) {
		this.personDialogs = personDialogs;
	}
	public Map<String, GroupDialog> getGroupDialogs() {
		return groupDialogs;
	}
	public void setGroupDialogs(Map<String, GroupDialog> groupDialogs) {
		this.groupDialogs = groupDialogs;
	}
	public Map<String, GroupDialog> getDiscussionDialogs() {
		return discussionDialogs;
	}
	public void setDiscussionDialogs(Map<String, GroupDialog> discussionDialogs) {
		this.discussionDialogs = discussionDialogs;
	}
	public OverallAnalystResult getOverallAnalystResult() {
		return overallAnalystResult;
	}
	public void setOverallAnalystResult(OverallAnalystResult overallAnalystResult) {
		this.overallAnalystResult = overallAnalystResult;
	}
	public List<PersonSimilarResult> getPersonSimilareResult() {
		return personSimilareResult;
	}
	public void setPersonSimilareResult(
			List<PersonSimilarResult> personSimilareResult) {
		this.personSimilareResult = personSimilareResult;
	}
	
	
	
}
